<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2021/7/7
  Time: 19:44
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=0">

    <title>地址管理</title>

    <link href="../AmazeUI-2.4.2/assets/css/admin.css" rel="stylesheet" type="text/css">
    <link href="../AmazeUI-2.4.2/assets/css/amazeui.css" rel="stylesheet" type="text/css">

    <link href="../css/personal.css" rel="stylesheet" type="text/css">
    <link href="../css/addstyle.css" rel="stylesheet" type="text/css">

    <script src="${pageContext.request.contextPath}/js/jquery-3.4.1.min.js" type="text/javascript"></script>
    <script type="text/javascript" src="../js/jsAddress.js"></script>
    <script src="../AmazeUI-2.4.2/assets/js/jquery.min.js" type="text/javascript"></script>
    <script src="../AmazeUI-2.4.2/assets/js/amazeui.js"></script>

</head>

<body>
<!--头 -->
<header>
    <article>
        <div class="mt-logo">
            <!--顶部导航条 -->
            <div class="am-container header">
                <ul class="message-l">
                    <div class="topMessage">
                        <div class="menu-hd">
                        </div>
                    </div>
                </ul>
                <ul class="message-r">
                    <div class="topMessage home">
                        <div class="menu-hd"><a href="/home" target="_top" class="h">商城首页</a></div>
                    </div>
                    <div class="topMessage my-shangcheng">
                        <div class="menu-hd MyShangcheng"><a href="/personCenter" target="_top"><i
                                class="am-icon-user am-icon-fw"></i>个人中心</a></div>
                    </div>
                    <div class="topMessage mini-cart">
                        <div class="menu-hd"><a id="mc-menu-hd" href="/cartList" target="_top"><i
                                class="am-icon-shopping-cart  am-icon-fw"></i><span>购物车</span></a>
                        </div>
                    </div>
                    <div class="topMessage favorite">
                        <div class="menu-hd"><a href="/toCollection" target="_top"><i
                                class="am-icon-heart am-icon-fw"></i><span>收藏夹</span></a></div>
                    </div>
                </ul>
            </div>

            <!--悬浮搜索框-->

            <div class="nav white">
                <div class="logoBig">
                    <li><img src="../images/logobig.png"/></li>
                </div>

                <div class="search-bar pr">
                    <a name="index_none_header_sysc" href="#"></a>
                    <form action="/search" method="post">
                        <input id="searchInput" name="searchMsg" type="text" placeholder="搜索"
                               autocomplete="off">
                        <input id="ai-topsearch" class="submit am-btn" value="搜索" index="1" type="submit">
                    </form>
                </div>
            </div>

            <div class="clear"></div>
        </div>
    </article>
</header>
<div class="nav-table">
    <div class="long-title"><span class="all-goods">全部分类</span></div>
    <div class="nav-cont">
        <ul>
            <li class="index"><a href="#">首页</a></li>
            <li class="qc"><a href="#">闪购</a></li>
            <li class="qc"><a href="#">限时抢</a></li>
            <li class="qc"><a href="#">团购</a></li>
            <li class="qc last"><a href="#">大包装</a></li>
        </ul>
        <div class="nav-extra">
            <i class="am-icon-user-secret am-icon-md nav-user"></i><b></b>我的福利
            <i class="am-icon-angle-right" style="padding-left: 10px;"></i>
        </div>
    </div>
</div>
<b class="line"></b>

<div class="center">
    <div class="col-main">
        <div class="main-wrap">

            <div class="user-address">
                <!--标题 -->
                <div class="am-cf am-padding">
                    <div class="am-fl am-cf"><strong class="am-text-danger am-text-lg">地址管理</strong> / <small>Address&nbsp;list</small>
                    </div>
                </div>
                <hr/>
                <ul class="am-avg-sm-1 am-avg-md-3 am-thumbnails">
                    <c:if test="${empty addrs}" var="flag">
                        <h2 style="font-size: 32px;margin:20px">暂无地址</h2>
                    </c:if>
                    <c:forEach items="${addrs}" var="address" varStatus="i">
                        <li class="user-addresslist <c:if test="${address.defaultTag eq 0}">defaultAddr</c:if>"
                            style="margin: 5px">
                            <a href="javascript:void(0);" class="new-option-r" id="defShopId"
                               defShopId="${address.shopId}"
                               onclick="setDefShopId(${address.shopId})"><i class="am-icon-check-circle"></i>默认地址</a>
                            <p class="new-tit new-p-re">
                                <span class="new-txt">${address.receiverName}</span>
                                <span class="new-txt-rd2">${address.receiverMobile}</span>
                            </p>
                            <div class="new-mu_l2a new-p-re">
                                <p class="new-mu_l2cw">
                                    <span class="title">地址：</span>
                                    <span class="province">${address.receiverProvince}</span>
                                    <span class="city">${address.receiverCity}</span>市
                                    <span class="dist">${address.receiverDistrict}</span>区
                                    <span class="street">${address.receiverAddress}</span></p>
                            </div>
                            <div class="new-addr-btn">
                                    <%--                                <a href="#"><i class="am-icon-edit"></i>编辑</a>--%>
                                    <%--                                <span class="new-addr-bar">|</span>--%>
                                <a href="javascript:void(0);" id="shopId"
                                   shopId="${address.shopId}"
                                   onclick="deleteAddr(${address.shopId})"><i class="am-icon-trash"></i>删除</a>
                            </div>
                        </li>

                    </c:forEach>
                </ul>


                <div class="clear"></div>
                <a class="new-abtn-type" data-am-modal="{target: '#doc-modal-1', closeViaDimmer: 0}">添加新地址</a>
                <!--例子-->
                <div class="am-modal am-modal-no-btn" id="doc-modal-1">

                    <div class="add-dress">

                        <!--标题 -->
                        <div class="am-cf am-padding">
                            <div class="am-fl am-cf"><strong
                                    class="am-text-danger am-text-lg">新增地址${addr.receiverMobile}</strong> / <small>Add&nbsp;address</small>
                            </div>

                        </div>
                        <hr/>

                        <form:form action="/toAddAddress" method="post" class="am-form am-form-horizontal"
                                   modelAttribute="addr">
                            <div class="am-u-md-12 am-u-lg-8" style="margin-top: 20px;">
                                <div class="am-form-group">
                                    <label for="user-name" class="am-form-label">收货人</label>
                                    <div class="am-form-content">
                                        <form:input type="text" id="user-name" placeholder="收货人"
                                                    path="receiverName" value=""/>
                                    </div>
                                </div>

                                <div class="am-form-group">
                                    <label for="user-phone" class="am-form-label">手机号码</label>
                                    <div class="am-form-content">
                                        <form:input id="user-phone" placeholder="手机号必填"
                                                    path="receiverMobile" value=""/>
                                    </div>
                                </div>
                                <div class="am-form-group">
                                    <label for="user-phone" class="am-form-label">所在地</label>
                                    <div class="am-form-content address">
                                        <form:select id="cmbProvince" name="cmbProvince"
                                                     path="receiverProvince"></form:select>
                                        <form:select id="cmbCity" name="cmbCity" path="receiverCity"></form:select>
                                        <form:select id="cmbArea" name="cmbArea" path="receiverDistrict"></form:select>
                                    </div>
                                </div>

                                <div class=" am-form-group">
                                    <label for="user-intro" class="am-form-label">详细地址</label>
                                    <div class="am-form-content">
                                        <form:textarea class="" rows="3" id="user-intro" placeholder="输入详细地址"
                                                       path="receiverAddress"></form:textarea>
                                        <small>100字以内写出你的详细地址...</small>
                                    </div>
                                </div>

                                <div class="am-form-group">
                                    <div class="am-u-sm-9 am-u-sm-push-3">
                                        <a class="am-btn am-btn-danger"><input class="am-btn am-btn-danger"
                                                                               type="submit" value="保存"></a>
                                        <a href="javascript: void(0)" class="am-close am-btn am-btn-danger"
                                           data-am-modal-close><input class="am-btn am-btn-danger" type="reset"
                                                                      value="取消"> </a>
                                    </div>
                                </div>
                            </div>
                        </form:form>

                    </div>

                </div>

            </div>


            <div class="clear"></div>

        </div>
        <!--底部-->
        <div class="footer">
            <div class="footer-hd">
                <p>
                    <a href="#">恒望科技</a>
                    <b>|</b>
                    <a href="#">商城首页</a>
                    <b>|</b>
                    <a href="#">支付宝</a>
                    <b>|</b>
                    <a href="#">物流</a>
                </p>
            </div>
            <div class="footer-bd">
                <p>
                    <a href="#">关于恒望</a>
                    <a href="#">合作伙伴</a>
                    <a href="#">联系我们</a>
                    <a href="#">网站地图</a>
                    <em>© 2015-2025 Hengwang.com 版权所有. 更多模板 <a href="http://www.cssmoban.com/" target="_blank"
                                                               title="模板之家">模板之家</a> - Collect from <a
                            href="http://www.cssmoban.com/" title="网页模板" target="_blank">网页模板</a></em>
                </p>
            </div>
        </div>
    </div>

    <aside class="menu">
        <ul>
            <li class="person active">
                <a href="/personCenter"><i class="am-icon-user"></i>个人中心</a>
            </li>
            <li class="person">
                <p><i class="am-icon-newspaper-o"></i>个人资料</p>
                <ul>
                    <li><a href="/toInformation">个人信息</a></li>
                    <li><a href="/toSafety">安全设置</a></li>
                    <li><a href="/toAddress">地址管理</a></li>
                </ul>
            </li>
            <li class="person">
                <p><i class="am-icon-balance-scale"></i>我的交易</p>
                <ul>
                    <li><a href="/toOrder">订单管理</a></li>
                    <li><a href="/toComment">评价商品</a></li>
                </ul>
            </li>
            <li class="person">
                <p><i class="am-icon-tags"></i>我的收藏</p>
                <ul>
                    <li><a href="/toCollection">收藏</a></li>
                    <li><a href="/toFoot">足迹</a></li>
                </ul>
            </li>

            <li class="person">
                <p><i class="am-icon-qq"></i>在线客服</p>
                <ul>
                    <li><a href="/toConsultation">商品咨询</a></li>
                    <li><a href="/toSuggest">意见反馈</a></li>
                </ul>
            </li>
        </ul>
    </aside>
</div>
</div>

</body>
<script type="text/javascript">
    function deleteAddr(shopId) {
        $.ajax({
            type: "post",
            url: "/deleteAddr",
            data: {
                "shopId": shopId
            },
            async: true,
            success: function (data) {
                location.href = "toAddress";
            }
        });

    }

    function setDefShopId(a) {
        var defShopId = a;
        $.ajax({
            type: "post",
            url: "/setDefShopId",
            data: {
                "defShopId": defShopId
            },
            async: true,
            success: function (data) {
            }
        });
    }


    addressInit('cmbProvince', 'cmbCity', 'cmbArea');
    $(document).ready(function () {
        $(".new-option-r").click(function () {
            $(this).parent('.user-addresslist').addClass("defaultAddr").siblings().removeClass("defaultAddr");
        });

        var $ww = $(window).width();
        if ($ww > 640) {
            $("#doc-modal-1").removeClass("am-modal am-modal-no-btn")
        }

    })

    $(":submit:eq(1)").click(function () {
        var name = $("#user-name").val();
        var phone = $("#user-phone").val();
        var textarea = $("textarea").val();
        if (name == "") {
            alert("请填写收货人");
            return false;
        }
        if (!checkTel(phone)) {
            return false;
        }
        if (textarea == "") {
            alert("请填写详细地址");
            return false;
        }
    })

    function checkTel(number) {
        var pattern = /(^(([0\+]\d{2,3}-)?(0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$)|(^(([0\+]\d{2,3})?(0\d{2,3}))(\d{7,8})((\d{3,}))?$)|(^0{0,1}1[3|4|5|6|7|8|9][0-9]{9}$)/;
        if (number == "") {
            alert("请输入手机号");
            return false;
        } else if (!pattern.test(number)) {
            alert("请输入合法手机号");
            return false;
        }
        return true;
    }

</script>
</html>